package system.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.UIManager;

import org.pushingpixels.substance.api.SubstanceLookAndFeel;
import org.pushingpixels.substance.api.skin.SubstanceGeminiLookAndFeel;

public class SettingsUtil
{

	public static String getDefaultFolder() throws FileNotFoundException, IOException
	{
		final String fileName = System.getProperty("user.home") + System.getProperty("file.separator") + "quickdoestyle.txt";
		final Properties properties = new Properties();
		org.pushingpixels.substance.api.SubstanceLookAndFeel laf = new SubstanceGeminiLookAndFeel();
		/*Runtime.getRuntime().addShutdownHook(new Thread()
		{
			@Override
			public void run()
			{
				try {
					if (properties.getProperty("userFolder") == null) {
						properties.setProperty("userFolder", "null");
					}
					properties.store(new FileOutputStream(fileName), fileName);
				} catch (Throwable t) {
					t.printStackTrace();
				}
			}
		});*/
		properties.load(new FileInputStream(fileName));
		String userFolder = properties.getProperty("userFolder");
		return userFolder;
	}

	public static void setDefaultFolder(final String folder) throws FileNotFoundException, IOException
	{
		final String fileName = System.getProperty("user.home") + System.getProperty("file.separator") + "quickdoestyle.txt";
		final Properties properties = new Properties();
		org.pushingpixels.substance.api.SubstanceLookAndFeel laf = new SubstanceGeminiLookAndFeel();
		Runtime.getRuntime().addShutdownHook(new Thread()
		{
			@Override
			public void run()
			{
				try {
					properties.setProperty("userFolder", folder);
					properties.store(new FileOutputStream(fileName), fileName);
				} catch (Throwable t) {
					t.printStackTrace();
				}
			}
		});
	}
}
